*------------------------------------------------------------------------------*
* Dependent variable: a11 prospective peace
*------------------------------------------------------------------------------*


*------------------
* Prepare working space
*------------------

set more off
clear


*------------------
* Open cleaned and operationalized survey data
*------------------

use "SL_survey_analysis.dta", clear

*------------------	
* Set the data as survey data
*------------------
svyset sl_id




*-------------------------------------------------------------------------------
* Model 5: proespective peace - A11 (binary): 		0 = political instability 
*													1 = peaceful times
*-------------------------------------------------------------------------------
		
	*-------------
	* Bivariate Model
	*-------------
		#delimit ;
		svy:   	logit
				a11_peace_trend			
				a3_ethnic_sinhalese
				a3_ethnic_tamil_moors 
		;
		#delimit cr
		estimate store m1_peace_biv


		
	*-------------
	* Full Model including media consumption
	*-------------
		#delimit ;
		svy:   	logit
				a11_peace_trend			
				a3_ethnic_sinhalese
				a3_ethnic_tamil_moors 
				x4_gender 				
				a1_age
				age2
				education_low 
				education_high				
				a7_econ_own_condition
				a9_econ_own_vs_all
				e4_phys_harm_war
				c1_c2_consumption_traditional 	// Baseline: family 
				c1_c2_consumption_online
		;
		#delimit cr
		estimate store m1_peace_full



*-------------------------------------------------------------------------------
* Export Table 2 (Full model; for manuscript)
*-------------------------------------------------------------------------------

#delimit;													
	esttab 	m1_peace_full
			using "table_2.tex", replace 
	b(3) se(3) 
	stats(	N,  fmt(0) 
			labels("Number of observations")
			) 
	order( 		a3_ethnic_sinhalese			
				a3_ethnic_tamil_moors 
				x4_gender 					
				a1_age
				age2
				education_low 
				education_high				
				a7_econ_own_condition
				a9_econ_own_vs_all
				e4_phys_harm_war
				c1_c2_consumption_traditional  
				c1_c2_consumption_online
			) 
	coeflabels( a3_ethnic_sinhalese				"Sinhalese"			
				a3_ethnic_tamil_moors 			"Tamil-Moor"
				x4_gender 						"Female"
				a1_age							"Age"
				age2							"Age\textsuperscript{2}"
				education_low 					"Low education"
				education_high					"High education"
				a7_econ_own_condition			"Absolute economic situation"
				a9_econ_own_vs_all				"Relative economic situation"
				e4_phys_harm_war				"Harmed in war"
				c1_c2_consumption_traditional  	"Use traditional media"
				c1_c2_consumption_online		"Use online media"
			) 
	label 
	star(\dag 0.10 * 0.05  ** 0.01 *** 0.001) 
		mlabels("(5)", prefix(\multicolumn{@span}{c}{) suffix(}))
	nonumber
	nobaselevels 
	nomtitles 
	eqlabels(,none)
	nolegend nonotes 
	booktabs 
	alignment(S) 
	substitute(\_ _)
	fragment
	prehead(
	\begin{table}[htbp]\centering
	\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
		\caption{Evaluation of peace prospects \label{tab:table_2}}
	\resizebox{7cm}{!}{		
	\begin{tabular}{l*{1}{S}} 
	\toprule		
	)
	postfoot(
	\bottomrule
	\multicolumn{2}{l}{\footnotesize Coefficients with robust standard errors.}\\	
	\multicolumn{2}{l}{\footnotesize $\dag$ p$<$0.1, * p$<$0.05, ** p$<$0.01, , *** p$<$0.001.}\\
	\end{tabular}
		}
		\end{table}		
		);



*-------------------------------------------------------------------------------
* Export Appendix Table including bivariate + full model
*-------------------------------------------------------------------------------

#delimit;													
	esttab 	m1_peace_biv 
			m1_peace_full
			using "table_a4.tex", replace 
	b(3) se(3) 
	stats(	N,  fmt(0) 
			labels("Number of observations")
			) 
	order( 		a3_ethnic_sinhalese			
				a3_ethnic_tamil_moors 
				x4_gender 					
				a1_age
				age2
				education_low 
				education_high				
				a7_econ_own_condition
				a9_econ_own_vs_all
				e4_phys_harm_war
				c1_c2_consumption_traditional  
				c1_c2_consumption_online
			) 
	coeflabels( a3_ethnic_sinhalese				"Sinhalese"			
				a3_ethnic_tamil_moors 			"Tamil-Moor"
				x4_gender 						"Female"
				a1_age							"Age"
				age2							"Age\textsuperscript{2}"
				education_low 					"Low education"
				education_high					"High education"
				a7_econ_own_condition			"Absolute economic situation"
				a9_econ_own_vs_all				"Relative economic situation"
				e4_phys_harm_war				"Harmed in war"
				c1_c2_consumption_traditional  	"Use traditional media"
				c1_c2_consumption_online		"Use online media"
			) 
	label 
	star(\dag 0.10 * 0.05  ** 0.01 *** 0.001) 
		mlabels("(1)" "(2)", prefix(\multicolumn{@span}{c}{) suffix(}))
	nonumber
	nobaselevels 
	nomtitles 
	eqlabels(,none)
	nolegend nonotes 
	booktabs 
	alignment(S) 
	substitute(\_ _)
	fragment
	prehead(
	\begin{table}[htbp]\centering
	\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
		\caption{Evaluation of peace prospects \label{tab:table_rob_5}}
	\resizebox{9cm}{!}{		
	\begin{tabular}{l*{2}{S}}  
	\toprule		
	)
	postfoot(
	\bottomrule
	\multicolumn{3}{l}{\footnotesize Coefficients with robust standard errors.}\\	
	\multicolumn{3}{l}{\footnotesize $\dag$ p$<$0.1, * p$<$0.05, ** p$<$0.01, , *** p$<$0.001.}\\
	\end{tabular}
		}
		\end{table}		
		);
